package com.hwhp.web.console.action;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import com.hwhp.common.BaseAction;
import com.hwhp.entity.SLstOfVal;
import com.hwhp.service.console.ListService;

public class AdminListAction extends BaseAction {
	private ListService listService = null;
	private SLstOfVal sLstOfVal = null;
	public String queryList(){
		HttpServletRequest request = this.getHttpRequest();
		List listLst = this.listService.queryAllList();
		request.setAttribute("listLst", listLst);
		return "queryListSuccess";
	}
	
	public String preListAdd(){
		return "preAddSuccess";
	}
	public String lstAdd(){
		HttpServletRequest request = this.getHttpRequest();
		this.listService.add(sLstOfVal);
		List listLst = this.listService.queryAllList();
		request.setAttribute("listLst", listLst);
		return "addSuccess";
	}
	
	public String preUpdateLst(){
		HttpServletRequest request = this.getHttpRequest();
		String id = request.getParameter("id");
		sLstOfVal = this.listService.getLstById(id);
		return "preUpdateSuccess";
	}
	
	public String updateLst(){
		HttpServletRequest request = this.getHttpRequest();
		this.listService.update(sLstOfVal);
		List listLst = this.listService.queryAllList();
		request.setAttribute("listLst", listLst);
		return "updateSuccess";
	}
	
	public String deleteLst(){
		HttpServletRequest request = this.getHttpRequest();
		String id = request.getParameter("id");
		this.listService.delete(id);
		List listLst = this.listService.queryAllList();
		request.setAttribute("listLst", listLst);
		return "deleteSuccess";
	}
	
	public ListService getListService() {
		return listService;
	}
	public void setListService(ListService listService) {
		this.listService = listService;
	}

	public SLstOfVal getsLstOfVal() {
		return sLstOfVal;
	}

	public void setsLstOfVal(SLstOfVal sLstOfVal) {
		this.sLstOfVal = sLstOfVal;
	}
   
}
